import React, { useState, createContext } from 'react'
import Father from './Father'

// useContext  在组件中接收到Context传递过来的内容

const Context = createContext()

export {
    Context
}

function HookContext() {
    const [val, setVal] = useState('val')
    return (
        <div>
            <h2>我是最外层的组件 -- { val }</h2>
            <button onClick={() => {
                setVal('aaaaa')
            }}>改变</button>
            <Context.Provider value={ val }>
                <Father/>
            </Context.Provider>
        </div>
    )
}


export default HookContext
